/*******************************************************************************

  Paying Outsourced Labor: Direct Evidence from Linked Temp Agency-Worker-Client Data

  By Andres Drenik, Simon Jäger, Pascuel Plotkin and Benjamin Schoefer
  January 7th, 2021

	DESCRIPTION: Creates Figure A.1 (a)

*******************************************************************************/




/********************************************************************************
***** Preliminaries
********************************************************************************/
set more off
cap log close
local curr_date = c(current_date)
log using "${logs}/FigA1a`curr_date'", replace


/****************************************************************************************
* Load Dataset
****************************************************************************************/

*Load dataset on summary statistics of firms
use "${intermediate_data_emp}/kk_table1.dta", clear

/****************************************************************************************
* Run Figures
****************************************************************************************/

*Merge to get the temp workers totals and percents
merge 1:1 date industry_code_2digit using "${intermediate_data_emp}/kk_table3.dta", keepusing(worker_user_firm) nogen

collapse (sum) worker worker_user_firm, by(industry_code_2digit year)

*Total workers per year
bys year: egen total_reg_workers = sum(worker)
bys year: egen total_temp_workers = sum(worker_user_firm)

*Generate shares per industry
gen perc_non_temp_workers = worker/total_reg_workers
gen perc_temp_workers = worker_user_firm/total_temp_workers

label define industry_2digit 15 "Manufacture of food products and beverages" 52 "Retail trade, repair of personal and household goods" 60 "Land transport; transport via pipelines" 24 "Manufacture of chemical products" 90 "Sewage and refuse disposal, sanitation" 74 "Other business activities" 45 "Construction" 80 "Education"
label values industry_code_2digit industry_2digit
drop if industry_code_2digit == . | industry_code_2digit == 75 | industry_code_2digit == inrange(industry_code_2digit, 95, 97) | industry_code_2digit == 0

*Plot Figure
twoway function y=x, range(0 0.2)|| scatter perc_temp_workers perc_non_temp_workers if year == 2016, mlabel(industry_code_2digit) mlabsize(vsmall) msize(tiny)/*
*/ ytitle("Industry’s Share of National Temp-Agency Employees", size(small)) xtitle("Industry’s Share of National Regular Employees", size(small)) scheme(vg_outc) legend(off) graphregion(color(white)) plotregion(color(white)) xsc(r(0 .2)) xlabel(0(.05).2)
graph export "$results_figures/proportion_temp_workers_non_temp_workers_industry_2016_detail.pdf", replace

log close
